package com.fwtai.api.controller;

import com.fwtai.config.ConfigFile;
import com.fwtai.entity.ReqPage;
import com.fwtai.service.api.ApiPromotionService;
import com.fwtai.tool.ToolClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 促销营销活动
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2023/5/17 15:03
 * @QQ号码 444141300
 * @Email service@yinlz.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@RestController
@Api(tags = "促销营销活动", description = "token选填")
@RequestMapping(ConfigFile.guest_v10 + "promotion")
public class PromotionController{

  private final ApiPromotionService apiPromotionService;

  public PromotionController(final ApiPromotionService apiPromotionService){
    this.apiPromotionService = apiPromotionService;
  }

  @ApiOperation(value = "获取的门店专属活动二维码", notes = "获取的门店专属活动二维码,返回门店的kid")
  @GetMapping("/getShopInfo")
  public void getShopInfo(final HttpServletResponse response){
    ToolClient.responseJson(apiPromotionService.getShopInfo(),response);
  }

  @ApiOperation(value = "获取信息及商品列表", notes = "获取信息及商品列表")
  @GetMapping("/getPromotionInfo")
  @ApiImplicitParam(name = "kid", value = "活动kid", dataType = "long", paramType = "query", required = true)
  public void getPromotionInfo(final Long kid,final HttpServletResponse response){
    ToolClient.responseJson(apiPromotionService.getpromotionInfo(kid),response);
  }

  @ApiOperation(value = "消费者商品信息及商品列表", notes = "消费者商品信息及商品列表")
  @GetMapping("/getStorePromotion")
  @ApiImplicitParams({
    @ApiImplicitParam(name = "kid", value = "活动kid", dataType = "long", paramType = "query", required = true),
    @ApiImplicitParam(name = "storeId", value = "门店kid", dataType = "long", paramType = "query", required = true)
  })
  public void getStorePromotion(final Long kid,final Long storeId,final HttpServletResponse response){
    ToolClient.responseJson(apiPromotionService.getStorePromotion(kid,storeId),response);
  }

  @ApiOperation(value = "门店获取活动列表(平台活动列表),默认仅含数据不含总记录数总条数", notes = "其参数是搜索过滤条件;排序的key为column值为返回的字段，排序关键字的key为order,其值可选正序ASC|倒序DESC<br/>注意调用端需要判断每次请求返回的条数是否小于每页大小或返回的code=201而停止下一次请求")
  @GetMapping("/listDataPage")
  public void listDataPage(final ReqPage reqPage,final HttpServletRequest request,final HttpServletResponse response){
    ToolClient.responseJson(apiPromotionService.listData(request),response);
  }
}